/**
 * Copyright (C) 2024-2030 Super BilGen & 超亿时代信息技术股份有限公司.All Rights Reserved.
 */
package cn.com.yang.task;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Component;

/**
 * @Model cn.com.yang.task.TestScheduledExecutor
 * @Desc TODO
 * @author yangyijin
 * @since 2025年4月1日-下午4:59:04
 */
@Component
public class TestScheduledExecutor {

	@PostConstruct
	public void init() {
		ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
		// 调度任务
		scheduler.schedule(TestScheduledExecutor::sendMessage, 10000, TimeUnit.SECONDS);
		System.out.println("任务已安排，将在 " + 10000 + "s后 执行。");
	}

	private static void sendMessage() {
		System.out.println("发送消息：今天晚上8点的任务已执行！");
	}
}
